﻿#ifndef _SQLERROR_H_H_
#define _SQLERROR_H_H_

#include "udatabase/sqlutility.h"
#include "kernel/Referenced.h"


namespace FD{
	namespace Utility{
		namespace DB{
			///<summary>
			///数据库错误信息类
			///</summary>
			class FD_DB_Export CSqlError :  public FD::Kernel::CReferenced
			{
			public:
				enum JASErrorType {
					ET_NoError,
					ET_ConnectionError,
					ET_StatementError,
					ET_TransactionError,
					ET_UnknownError
				};
				///<summary>
				///构造函数
				///</summary>
				///<param name=""></param>
				///<returns></returns>
				CSqlError();
				///<summary>
				///构造函数
				///</summary>
				///<param name="driverText">驱动错误文本</param>
				///<returns></returns>
				CSqlError( const FD::Kernel::FdUnicodeString& driverText); 
				///<summary>
				///构造函数
				///</summary>
				///<param name="driverText">驱动错误文本</param>
				///<param name="databaseText">数据库错误文本</param>
				///<returns></returns>
				CSqlError( const FD::Kernel::FdUnicodeString& driverText ,const FD::Kernel::FdUnicodeString& databaseText);
				///<summary>
				///构造函数
				///</summary>
				///<param name="driverText">驱动错误文本</param>
				///<param name="databaseText">数据库错误文本</param>
				///<param name="type">错误类型</param>
				///<returns></returns>
				CSqlError( const FD::Kernel::FdUnicodeString& driverText ,
					const FD::Kernel::FdUnicodeString& databaseText,
					JASErrorType type);
				///<summary>
				///构造函数
				///</summary>
				///<param name="driverText">驱动错误文本</param>
				///<param name="databaseText">数据库错误文本</param>
				///<param name="type">错误类型</param>
				///<param name="number">错误个数</param>
				///<returns></returns>
				CSqlError( const FD::Kernel::FdUnicodeString& driverText,
					const FD::Kernel::FdUnicodeString& databaseText,
					JASErrorType type ,
					INT32 number);
				///<summary>
				///拷贝构造函数
				///</summary>
				///<param name="other">错误类</param>
				///<returns></returns>
				CSqlError(const CSqlError& other);
				///<summary>
				///赋值操作符的重载
				///</summary>
				///<param name="other">错误类</param>
				///<returns></returns>
				FD::Utility::DB::CSqlError& operator=(const FD::Utility::DB::CSqlError& other);
				///<summary>
				///析构函数
				///</summary>
				~CSqlError();
				///<summary>
				///获取驱动错误文本
				///</summary>
				///<param name=""></param>
				///<returns>驱动错误文本</returns>
				const FD::Kernel::FdUnicodeString& driverText() const;
				///<summary>
				///设置驱动错误文本
				///</summary>
				///<param name="driverText">驱动错误文本</param>
				///<returns></returns>
				void setDriverText(const FD::Kernel::FdUnicodeString& driverText);
				///<summary>
				///获取数据库错误文本
				///</summary>
				///<param name=""></param>
				///<returns>数据库错误文本</returns>
				const FD::Kernel::FdUnicodeString& databaseText() const;
				///<summary>
				///设置数据库错误文本
				///</summary>
				///<param name="databaseText">数据库错误文本</param>
				///<returns></returns>
				void setDatabaseText(const FD::Kernel::FdUnicodeString& databaseText);
				///<summary>
				///获取错误类型
				///</summary>
				///<param name=""></param>
				///<returns>错误类型</returns>
				JASErrorType type() const;
				///<summary>
				///设置错误类型
				///</summary>
				///<param name="type">错误类型</param>
				///<returns></returns>
				void setType(JASErrorType type);
				///<summary>
				///获取错误个数
				///</summary>
				///<param name=""></param>
				///<returns>错误个数</returns>
				int number() const;
				///<summary>
				///设置错误个数
				///</summary>
				///<param name="number">错误个数</param>
				///<returns></returns>
				void setNumber(int number);
				///<summary>
				///获取由驱动错误和数据库错误组成的字符串
				///</summary>
				///<param name=""></param>
				///<returns>驱动错误和数据库错误组成的字符串</returns>
				FD::Kernel::FdUnicodeString text() const;
				///<summary>
				///错误是否被设置
				///</summary>
				///<param name=""></param>
				///<returns>被设置返回true,否则返回false</returns>
				bool isValid() const;

			private:
				FD::Kernel::FdUnicodeString driverError;
				FD::Kernel::FdUnicodeString databaseError;
				JASErrorType errorType;
				int errorNumber;
			};
		}
	} 
} 

#endif // _SQLERROR_H_H_

